/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/4/29
 * \* Time: 20:56
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 剪绳子2 {
    public int cuttingRope(int n) {
        if(n<4) return n-1;

        long res=1;
        while(n>4){
            res*=3;
            res=res%1000000007;
            n-=3;
        }
        return (int)(res*n%1000000007);
    }
}